package com.mowh.multithreading.thread.per.message;

import java.util.concurrent.Executor;

/**
 * @author mowh1gd
 * @create 2023/11/23 11:31
 */
public class ExecutorHost {
    private final Helper helper = new Helper();
    private final Executor executor;

    public ExecutorHost(Executor executor) {
        this.executor = executor;
    }

    public void request(final int count, final char c) {
        System.out.println("    request(" + count + ", " + c + ")  BEGIN");
        executor.execute(//java.util.concurrent.Executor：隐式创建线程
                new Runnable() {
                    @Override
                    public void run() {
                        helper.handle(count, c);
                    }
                }
        );
        System.out.println("    request(" + count + ", " + c + ")  END");
    }

}
